Lua utility module RingInventory

This module enables classic ring inventory in TEN levels.

To enable ring inventory in a level, require this module once in your level script or in Autoexec.lua:

local RingInventory = require("Engine.RingInventory.Inventory")

Global ring inventory settings. Settings is composed of several sub-tables, and each section of the Settings documentation corresponds to one of these sub-tables. These configuration groups are located in Settings.lua script file inside RingInventory folder.

It is possible to change settings on a per-level basis via RingInventory.GetSettings and RingInventory.SetSettings functions, but keep in mind that Settings.lua is reread every time the level is reloaded. Therefore, you need to implement custom settings management in your level script if you want to override global settings.

Functions

GetSettings() Get settings tables for RingInventory.
SetSettings(newSettings) Set settings tables for RingInventory.

Background

enable Whether the background sprite is rendered.
objectID The object ID used to source the background sprite.
spriteID The sprite index within the object to use as the background.
color Tint color applied to the background sprite.
position Screen position of the background sprite's anchor point, in percent.
rotation Rotation of the background sprite in degrees.
scale Scale of the background sprite as a percentage of screen size.
alignMode Alignment mode used when positioning the background sprite.
scaleMode Scaling mode used when sizing the background sprite.
blendMode Blend mode used when rendering the background sprite.
alpha Overall opacity of the background sprite.

SoundMap

playerNo Sound played when Lara has no item available.
menuRotate Sound played when rotating the inventory ring.
menuSelect Sound played when hovering over or highlighting a menu option.
menuChoose Sound played when confirming a menu choice.
menuCombine Sound played when combining two inventory items.
inventoryOpen Sound played when the inventory is opened.
inventoryClose Sound played when the inventory is closed.

ColorMap

plainText Color used for standard body text in the inventory.
headerText Color used for section headers and titles.
optionText Color used for selectable option text.
background Background tint color for the inventory.
inventoryAmbient Ambient light color cast on inventory item models.
itemHidden Color used to render hidden inventory items.
itemDeselected Color used to render unselected inventory items.
itemSelected Color used to render the currently selected inventory item.
neutral Color used to render the neutral sprites.

Animation

inventoryAnimTime Duration of the inventory ring open/close transition.
itemAnimTime Duration of the per-item spin or presentation animation.
skipRingClose Skip the ring collapse animation when closing the inventory.
transitionSpeed Speed at which inventory text fades in and out.

Statistics

progressTime Progress time while in Inventory.
gameStats Display the full game statistics in Statistics mode.


Functions

GetSettings()
Get settings tables for RingInventory.

Returns:

    Settings Current settings table
SetSettings(newSettings)
Set settings tables for RingInventory.

Parameters:

  • newSettings Settings Required settings table

Background

These settings control the inventory background sprite display.

Usage:

-- In the level's lua file
local settings = RingInventory.GetSettings()
settings.Background.enable = false
RingInventory.SetSettings(settings)
enable
Whether the background sprite is rendered.
  • enable bool If true, the background sprite will be displayed behind the inventory. Default: true.
objectID
The object ID used to source the background sprite.
  • objectID ObjID Object ID for the background's sprite. Default: TEN.Objects.ObjID.DIARY_ENTRY_SPRITES.
spriteID
The sprite index within the object to use as the background.
  • spriteID int Sprite ID from the specified object for the background's sprite. Default: 0.
color
Tint color applied to the background sprite.
  • color Color Color of background's sprite. Default: TEN.Color(255, 255, 255).
position
Screen position of the background sprite's anchor point, in percent.
  • position Vec2 X,Y position of the background sprite in screen percent (0-100). Default: TEN.Vec2(50, 50).
rotation
Rotation of the background sprite in degrees.
  • rotation float Rotation of the background's sprite (0-360), in degrees. Default: 0.
scale
Scale of the background sprite as a percentage of screen size.
  • scale Vec2 X,Y Scaling factor for the background's sprite. Default: TEN.Vec2(100, 100).
alignMode
Alignment mode used when positioning the background sprite.
  • alignMode AlignMode Alignment for the background's sprite. Default: TEN.View.AlignMode.CENTER.
scaleMode
Scaling mode used when sizing the background sprite.
  • scaleMode ScaleMode Scaling for the background's sprite. Default: TEN.View.ScaleMode.STRETCH.
blendMode
Blend mode used when rendering the background sprite.
  • blendMode BlendID Blending modes for the background's sprite. Default: TEN.Effects.BlendID.ALPHA_BLEND.
alpha
Overall opacity of the background sprite.
  • alpha int Opacity value from 0 (fully transparent) to 255 (fully opaque). Default: 255.

SoundMap

These settings map inventory UI events to sound effect IDs. Sound IDs correspond to entries in the game's sound catalogue.

Usage:

-- Example of overriding the inventory open sound
-- In the level's lua file
local settings = RingInventory.GetSettings()
settings.SoundMap.inventoryOpen = 42
RingInventory.SetSettings(settings)
playerNo
Sound played when Lara has no item available.
  • playerNo int Sound effect ID triggered when the player attempts to use an unavailable item. Default: 2.
menuRotate
Sound played when rotating the inventory ring.
  • menuRotate int Sound effect ID triggered while scrolling through inventory items. Default: 108.
menuSelect
Sound played when hovering over or highlighting a menu option.
  • menuSelect int Sound effect ID triggered on item selection highlight. Default: 109.
menuChoose
Sound played when confirming a menu choice.
  • menuChoose int Sound effect ID triggered when the player confirms a selected action. Default: 111.
menuCombine
Sound played when combining two inventory items.
  • menuCombine int Sound effect ID triggered when two compatible items are combined. Default: 114.
inventoryOpen
Sound played when the inventory is opened.
  • inventoryOpen int Sound effect ID triggered when the inventory ring is opened. Default: 109.
inventoryClose
Sound played when the inventory is closed.
  • inventoryClose int Sound effect ID triggered when the inventory ring is closed. Default: 109.

ColorMap

These settings define the colors used throughout the inventory UI. Colors are of type Color.

Usage:

-- Example of changing the selected item highlight color
-- In the level's lua file
local settings = RingInventory.GetSettings()
settings.ColorMap.itemSelected = TEN.Color(200, 180, 60, 255)
RingInventory.SetSettings(settings)
plainText
Color used for standard body text in the inventory.
  • plainText Color Applied to descriptive text. Default: Flow.GetSettings().UI.plainTextColor.
headerText
Color used for section headers and titles.
  • headerText Color Applied to inventory category headings and titles. Default: Flow.GetSettings().UI.headerTextColor.
optionText
Color used for selectable option text.
  • optionText Color Applied to text entries. Default: Flow.GetSettings().UI.optionTextColor.
background
Background tint color for the inventory.
  • background Color Semi-transparent overlay color drawn behind inventory content. The alpha channel determines the strenght of the effect. Default: Color(64, 64, 64, 128).
inventoryAmbient
Ambient light color cast on inventory item models.
  • inventoryAmbient Color Light applied to Inventory items. Default: Color(255, 255, 128).
itemHidden
Color used to render hidden inventory items.
  • itemHidden Color Fully transparent; items with this color are invisible in the ring. Default: Color(0, 0, 0, 0).
itemDeselected
Color used to render unselected inventory items.
  • itemDeselected Color Tint applied to items that are not currently highlighted. Default: Color(32, 32, 32, 255).
itemSelected
Color used to render the currently selected inventory item.
  • itemSelected Color Tint applied to the item the player has focused on. Default: Color(128, 128, 128, 255).
neutral
Color used to render the neutral sprites.
  • neutral Color Tint applied to the sprites. Default: Color(255, 255, 255, 255).

Animation

These settings determine the animations of the Inventory.

Usage:

-- In the level's lua file
local settings = RingInventory.GetSettings()
settings.Animations.skipRingClose = true
RingInventory.SetSettings(settings)
inventoryAnimTime
Duration of the inventory ring open/close transition.
  • inventoryAnimTime float Time in seconds for the ring to animate. Default: 0.5.
itemAnimTime
Duration of the per-item spin or presentation animation.
  • itemAnimTime float Time in seconds for an individual item to animate into its focused pose. Default: 0.2.
skipRingClose
Skip the ring collapse animation when closing the inventory.
  • skipRingClose bool If true, the inventory closes instantly without playing the ring-retract animation. Default: false.
transitionSpeed
Speed at which inventory text fades in and out.
  • transitionSpeed float Alpha change applied per frame. Higher values cause faster fades. Default: 50.

Statistics

These settings control time progression in Inventory and Game statistics display.

Usage:

-- Example of disabling the game statistics screen
-- In the level's lua file
local settings = RingInventory.GetSettings()
settings.Statistics.gameStats = false
RingInventory.SetSettings(settings)
progressTime
Progress time while in Inventory. Stopwatch hands are also moving.
  • progressTime bool If true, time is progressed in the inventory. Default: true.
gameStats
Display the full game statistics in Statistics mode.
  • gameStats bool If true, full game statistics are show in Statistics mode in Inventory. Default: true.
generated by TEN-LDoc (a fork of LDoc 1.4.6)